home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / games / 2a / applicat.ion / slider.doc < prev    next >
Text File  |  1985-05-29  |  7KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.          Dialog box slider subroutines
  8.  
  9.          by Tom Hudson
  10.  
  11.  
  12.          Here's a set of subroutines that will help GEM developers put
  13.          sliders similar to those on GEM windows in their dialog
  14.          boxes.  Up to ten sliders per window are supported (more can
  15.          be added by changing four arrays), both horizontal and
  16.          vertical, in any combination.  They can be monitored at the
  17.          same time as other items in the dialog, and each slider can
  18.          be independently scaled.  The slider subroutine returns true
  19.          step values (not 0-1000 as in GEM sliders), so no additional
  20.          processing is necessary.
  21.  
  22.          There are four other files in the DL area that you will want
  23.          to download.  These are:
  24.  
  25.          SLIDER.C -- C source for a slider test program
  26.          SLIDES.H -- Resource index names for the test program
  27.          SLIDES.DEF -- Resource definition file
  28.          SLIDES.RSC -- Slider test dialog resource for test program
  29.  
  30.  
  31.          Setting up the dialog.
  32.  
  33.          Using the Resource Construction Set, load the SLIDES.RSC
  34.          resource.  This file contains one dialog box, which
  35.          demonstrates how to set up the sliders in your own dialogs.
  36.  
  37.          To build the necessary items for a slider, you will need two
  38.          buttons and two boxes.  One of the boxes will be the slider
  39.          "track", which limits the movement of the slider itself.
  40.          Make the slider box as big as required.  To maintain user
  41.          recognition, it is suggested that a track be defined with a
  42.          dot pattern, like the GEM window sliders.  NAME the track
  43.          appropriately (i.e. TRACK1).  The track can be any width, and
  44.          can run horizontally or vertically.
  45.  
  46.          Next, place another box ON the track box.  You will be warned
  47.          that this movement changes the object order.  This is OK.
  48.          Size this new box so that it fits inside the track -- this is
  49.          the movable slider.  NAME it appropriately (i.e. SLIDER1).
  50.          Finally, set the slider object so that it is a TOUCHEXIT item
  51.          (no other options selected).
  52.  
  53.          Now define two buttons with arrow characters in the two
  54.          directions appropriate for the slider, labeling them
  55.          accordingly (i.e. UP1/DOWN1 or LEFT1/RIGHT1).  Make these
  56.          items TOUCHEXIT items and place them at either end of the
  57.          slider track.
  58.  
  59.          Build your dialog box with as many sliders as you like, just
  60.          remember to label all four slider elements and make the
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.          slider and the direction buttons TOUCHEXIT items.
  73.  
  74.          The program.
  75.  
  76.          The SLIDER.C program shows how to handle a dialog box with
  77.          four independent sliders in it (two horizontal, two
  78.          vertical).  The code isn't fancy or particularly optimized,
  79.          but then I wrote it at 2 A.M.  It does things the quickest
  80.          way I could think of, and you may want to clean it up.
  81.          Whatever it looks like, it works.
  82.  
  83.          To use the slider routines in your programs, you will need
  84.          the four slider functions (hreset, vreset, do_hslider &
  85.          do_vslider) and their control variables (slidstep[],
  86.          slidacc[], slidpos[] and slidmax[]).
  87.  
  88.          The actual slider usage starts by drawing the dialog box with
  89.          the objc_draw call.  Next, you must initialize all the
  90.          sliders you use.  This is done with the hreset and vreset
  91.          calls.
  92.  
  93.          To initialize a slider, you must provide the slider number
  94.          (0-9), the address of the dialog box form, the index of the
  95.          slider's track object, the index of the slider object itself,
  96.          the maximum slider setting, and the initial slider setting.
  97.  
  98.          For a slider with 35 possible positions, the maximum slider
  99.          setting would be set to 34 (because the range is 0-34).  To
  100.          make the slider initially at the left of a horizontal slider
  101.          or the top of a vertical slider, set the initial slider
  102.          setting to 0.  Setting this to 34 will place the slider at
  103.          the right of a horizontal slider or the bottom of a vertical
  104.          slider.  You can set the initial position to anything between
  105.          0 and the maximum; the slider subroutine automatically
  106.          determines the proper setting for anything in-between.
  107.  
  108.          For example, the first slider in the example program
  109.          (SLIDER0) has 11 possible positions and is initially set to
  110.          position 1.
  111.  
  112.          After all sliders are initialized, you call form_do to
  113.          monitor the user's interaction with the dialog.
  114.  
  115.          Because the slider and its direction control buttons are
  116.          TOUCHEXIT items, as soon as the mouse is clicked on them the
  117.          form_do function will return with their index numbers.  You
  118.          then check the index, seeing if it's a slider or button for a
  119.          particular slider and call the do_hslider or do_vslider
  120.          function, passing the slider's index number to the function,
  121.          along with the dialog's address, the track index, slider
  122.          index, control button indexes and the index number of the
  123.          item that caused the exit from the form_do.
  124.  
  125.          The do_hslider and do_vslider functions will process the
  126.          slider and return when finished.  You should then re-enter
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.          the form_do.  Repeat this process until the form_do returns
  139.          with one of the exit buttons (i.e. OK or CANCEL).
  140.  
  141.          If the form was exited with the OK button, you must take the
  142.          slider values and place them into your work areas for
  143.          processing.  The settings of the sliders can be found in the
  144.          slidpos[] array.  These settings will be from 0 to the
  145.          maximum value you selected in the hreset or vreset call.
  146.  
  147.          The demo program will repeat the slider test dialog each time
  148.          it is exited and you press a key other than the RETURN key.
  149.          This allows you to see how the OK and Cancel buttons affect
  150.          the sliders.  To quit the program, exit the dialog and press
  151.          RETURN.
  152.  
  153.          This set of functions was designed to work with just about
  154.          any application or dialog and should work fine in your
  155.          programs.  Just examine the example program and experiment.
  156.          Modification of these functions should be relatively easy --
  157.          have fun.  If you have any trouble, drop me a note on the
  158.          16-bit SIG.
  159.  
  160.          -Tom Hudson 70775,424
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.